import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-stars',
  templateUrl: './stars.component.html',
  styleUrls: ['./stars.component.css']
})
export class StarsComponent implements OnInit {

  // 装饰器：表示该组件的rating属性应该由父组件传递
  @Input()
  private rating: number = 0;

  private stars: boolean[];

  constructor() { }
  ngOnInit() {
    this.stars = [false, false, true, true, true]
    this.stars = [];
    for (let i = 1; i <= 5; i++) {
      this.stars.push(i > this.rating)
    }
  }

}
